#ifndef DRAWWIDGET_H
#define DRAWWIDGET_H

#include "Macro.h"
#include "SystemData.h"

#include <QPainter>
#include <QMouseEvent>
#include <QOpenGLWidget>


enum class RotateType
{
    Rotate_0     = 0,
    Rotate_90    = 1,
    Rotate_180   = 2,
    Rotate_270   = 3,
};

class CDrawWidget : public QOpenGLWidget
{
    Q_OBJECT

public:
    CDrawWidget(QWidget* parent = nullptr);
    ~CDrawWidget();

    void paintEvent(QPaintEvent* event) override;
    void resizeEvent(QResizeEvent* event) override;
    void mousePressEvent(QMouseEvent* event) override;
    void mouseMoveEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;

    inline void SetShapeType(const ShapeType &shapeType){m_ShapeType = shapeType;}
    inline void SetPenColor (const PenColor &penColor){m_PenColor = penColor;}
    int RotateLeft();
    int RotateRight();

private:
    CSystemData*   m_pSystemData;

    bool           m_bLBtnClicked;//鼠标左键是否按下
    RotateType     m_RotateType;
    PenColor       m_PenColor;
    ShapeType      m_ShapeType;//当前绘画的图形类型
    QPoint         m_ClickPoint;//鼠标点击的坐标
    QPoint         m_MovePoint;//鼠标移动的坐标
    QPoint         m_TextPoint;

    QPen           m_BlackPen;//黑画笔
    QPen           m_RadPen;
    QPen           m_BluePen;
    QFont          m_TextFont;//文字字体
    QBrush         m_WhiteBrush;
    QBrush         m_NullBrush;//空画刷
};

#endif // DRAWWIDGET_H
